package org.arkeologgr.appening.views.overlays;
import java.util.ArrayList;
import java.util.List;

import org.arkeologgr.appening.domain.CultureItem;

import android.content.Context;
import android.graphics.drawable.Drawable;
import com.google.android.maps.ItemizedOverlay;

public class CultureItemOverlay extends ItemizedOverlay<CultureItemOverlayItem>{
	
	public interface CultureItemOverlayListener{
		public void onCultureItemTapped(CultureItem item);
	}
	
	private CultureItemOverlayListener mListener;
	public CultureItemOverlay(Drawable defaultMarker, CultureItemOverlayListener listener) {
		super(boundCenterBottom(defaultMarker));
		mListener = listener;
		mItems = new ArrayList<CultureItemOverlayItem>();
		populate();
	}

	private List<CultureItemOverlayItem> mItems;
	
	public void addOverlay(CultureItem cultureItem){
		CultureItemOverlayItem item = new CultureItemOverlayItem(cultureItem);
		mItems.add(item);
		populate();
	}
	
	@Override
	protected CultureItemOverlayItem createItem(int i) {
		return mItems.get(i);
	}

	@Override
	public int size() {
		return mItems.size();
	}
	
	@Override
	protected boolean onTap(int index) {
		CultureItemOverlayItem tappedItem = mItems.get(index);
		mListener.onCultureItemTapped(tappedItem.getItem());
		return true;
	}

}
